<?php
	// set variabel dan nilainya dari form upload foto
	// 1. nama file foto
	$filename = $_FILES['fphoto']['name'];
	// 2. kategori foto
	$category = $_POST['kateg'];
	// 3. hak akses
	$access = $_POST['access'];
	// 4. hak komen
	$comment = $_POST['comment'];
	// 5. deskripsi
	$desc = $_POST['desc'];
	// 6. keywords
	// 7. tanggal pengambilan foto
	$tgl_ambil = $_POST['tgl_ambil'];
	// 8. waktu upload foto
	$time_upload = date("d/m/y : H:i:s", time());
	// 9. tag foto
	// 10. iduser
	$iduser = $_COOKIE['id_active'];
	
	require_once('config.php');
	
	$query = "INSERT INTO foto (iduser, pic, deskripsi, tgl_foto, tgl_upload, idkategori, hak_akses, hak_komen) VALUES ('".$iduser."', '".$filename."','".$desc."', '".$tgl_ambil."', '".$time_upload."', '".$category."', '".$access."', '".$comment."')";
	$result = mysql_query($query);
	
	$uploads_dir = 'uploads/';
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES['fphoto']['tmp_name'];
        $name = $_FILES['fphoto']['name'];
		move_uploaded_file($tmp_name, $uploads_dir.$name);
	}
	
	if (!$result) {
		die('Error : ' .mysql_error());
	} else {
		header("Location:".$url."photo.php");
	}
	
	//echo date("d/m/y : H:i:s", $time_upload) ;
	//echo $iduser;
?>